/**
 * 
 */
package monitor;

import java.beans.PropertyChangeEvent;
import java.util.Timer;
import java.util.TimerTask;

/**
 * @author Robbie
 *
 */
public class HeartBeatMaker extends Maker {
	
	private Timer myTimer;
	private int myBPM,myBeats,myDelay;
		
	/**
	 * @param bpm
	 * @throws Exception 
	 */
	public HeartBeatMaker(String pktID, int bpm, int delay){
		super(pktID);
		myBPM = bpm;
		myTimer = new Timer();
		myBeats = 0;
		myDelay = delay;
		setPacketData(Integer.toString(myBPM));
	}
	
	/**
	 * @throws Exception 
	 * 
	 */
	public HeartBeatMaker(){
		super("HRT BEAT");
		myBPM = 150;
		myTimer = new Timer();
		myBeats = 0;
		myDelay = 5000;
		setPacketData(Integer.toString(myBPM));
	}
	
	/**
	 * 
	 */
	public void run(){
		myTimer.scheduleAtFixedRate(new TimerTask(){

			@Override
			public void run() {
//				System.out.println("Beat");
				myBeats++;
				broadcastPacket();
			}
			
		}, 0, myDelay);
	}
	
	
	@Override
	public void propertyChange(PropertyChangeEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
